package com.wc.alorithm_blue_bridge._前缀和与差分.Q7943;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * @Author congege
 * @Description 区间最大和
 * https://www.lanqiao.cn/problems/7943/learning/?problem_list_id=25&page=1
 * @Date Created in 2023/12/19-22:46
 */
public class Main {
    static int maxN = (int) 1e5 + 10;
    static long[] pre = new long[maxN];
    static FastReader in = new FastReader();

    public static void main(String[] args) {
        int n = in.nextInt();
        int k = in.nextInt();
        for (int i = 1; i <= n; i++) {
            pre[i] = pre[i - 1] + in.nextInt();
        }
        long ans = 0;
        for (int i = k; i <= n; i++) {
            ans = Math.max(ans,pre[i] - pre[i - k]);
        }
        System.out.println(ans);
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
}
